﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

struct S3
{
	double d;// 对齐数 8
	char c; //  对齐数1
	int i; //   对齐数4
}s3;

int main()
{
	////一维数组
	//int a[] = { 1,2,3,4 };
	//printf("%d\n", sizeof(a));  // 16 数组
	//printf("%d\n", sizeof(a + 0)); // 4 zhi
	//printf("%d\n", sizeof(*a));  // 4
	//printf("%d\n", sizeof(a + 1)); //4 zhi
	//printf("%d\n", sizeof(a[1]));  //4
	//printf("%d\n", sizeof(&a));    //4 z
	//printf("%d\n", sizeof(*&a));   // 16 数组
	//printf("%d\n", sizeof(&a + 1)); // 4 z
	//printf("%d\n", sizeof(&a[0]));  // 4 z
	//printf("%d\n", sizeof(&a[0] + 1)); // 4 z

	//// 有报错
	//char arr[] = "abcdef";
	//printf("%d\n", sizeof(arr)); 
	//printf("%d\n", sizeof(arr + 0)); 
	//printf("%d\n", sizeof(*arr)); 
	//printf("%d\n", sizeof(arr[1])); 
	//printf("%d\n", sizeof(&arr)); 
	//printf("%d\n", sizeof(&arr + 1)); 
	//printf("%d\n", sizeof(&arr[0] + 1));
	//printf("%d\n", strlen(arr)); 
	//printf("%d\n", strlen(arr + 0)); 
	//printf("%d\n", strlen(*arr)); 
	//printf("%d\n", strlen(arr[1])); 
	//printf("%d\n", strlen(&arr)); 
	//printf("%d\n", strlen(&arr + 1)); 
	//printf("%d\n", strlen(&arr[0] + 1));

	////二维数组
	//int a[3][4] = {0};
	//printf("%d\n",sizeof(a));        //  单行 48
	//printf("%d\n",sizeof(a[0][0]));  // 4
	//printf("%d\n", sizeof(*(a[0] + 1))); // 4
	//printf("%d\n", sizeof(a + 1));        // 4 z
	//printf("%d\n",sizeof(a[0]));     // 16
	//printf("%d\n", sizeof(&a[0] + 1));    // 4 z
	//printf("%d\n",sizeof(a[0]+1));   // 16  4  

	//int a[3][4] = { 0 };
	//printf("%d\n",sizeof(*(a+1)));     // 4    16
	//printf("%d\n",sizeof(*(&a[0]+ 1))); // 4   16
	//printf("%d\n",sizeof(*a));        // 4 z   16
	//printf("%d\n",sizeof(a[3]));      // 4 z   16

	//cout << endl;
	//printf("%d\n", sizeof(a[0] + 1));

	// 要区分出转义字符，如"\\", "\123",
	//char s[] = "\\123456\123456\t";
	//printf(" %d\n", strlen(s));

	//char a[30] = "liaowo6508@163.com";
	//char copy[30] = { 0 };
	//strcpy(copy, a);
	//const char* tok = "@.";
	//char* pro = NULL;
	//// 利用该函数会保存分割符号下一个字符指针的特性
	//// 第一次调用
	//pro = strtok(copy, tok);
	//while (pro != NULL)
	//{
	//	printf("%s\n", pro);
	//	// 后续调用第一参数设置null即可
	//	pro = strtok(NULL, tok);
	//}

	//printf("%u\n", offsetof(struct S3, d));  //  0
	//printf("%u\n", offsetof(struct S3, c));  //  8
	//printf("%u\n", offsetof(struct S3, i)); //12
	//cout << sizeof(S3) << endl;  //16字节


	struct S
	{
		char a : 3;
		char b : 4;
		char c : 5;
		char d : 4;
	};
	struct S s = { 0 };
	s.a = 10;
	s.b = 12;
	s.c = 3;
	s.d = 4;

	int i = 1;
	
	/*printf("%u\n", &s);
	printf("%u\n", &i);*/


	return 0;
}

















